

local jianxiong = fk.CreateSkill{
  name = "lingling__jianxiong",
}

Fk:loadTranslationTable{
  ["lingling__jianxiong"] = "奸雄",
  [":lingling__jianxiong"] = "当你受到伤害后，你可以获得对你造成伤害的牌并摸一张牌。当其他角色使用普通锦囊牌指定你为唯一目标后，"..
  "你可以失去1点体力使之无效，然后你获得之。",

  ["#lingling__jianxiong-invoke"] = "奸雄：是否失去1点体力，令 %dest 对你使用的%arg无效并获得之？",
}

jianxiong:addEffect(fk.Damaged, {
  anim_type = "masochism",
  on_use = function(self, event, target, player, data)
    if data.card and player.room:getCardArea(data.card) == Card.Processing then
      player.room:obtainCard(player, data.card, true, fk.ReasonJustMove, player, jianxiong.name)
    end
    if not player.dead then
      player:drawCards(1, jianxiong.name)
    end
  end,
})

jianxiong:addEffect(fk.TargetConfirmed, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(jianxiong.name) and
      data:isOnlyTarget(player) and data.card:isCommonTrick() and data.from ~= player
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = jianxiong.name,
      prompt = "#lingling__jianxiong-invoke::"..data.from.id..":"..data.card:toLogString(),
    })
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    data.use.nullifiedTargets = table.simpleClone(player.room.players)
    room:loseHp(player, 1, jianxiong.name)
    if not player.dead and room:getCardArea(data.card) == Card.Processing then
      room:obtainCard(player, data.card, true, fk.ReasonJustMove, player, jianxiong.name)
    end
  end,
})

return jianxiong
